package cn.gok.oop;
import java.util.Scanner;
class Person {

    private String name;
    private String sex;
    private int age;
    private Boolean isMarried;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Boolean getIsMarried() {
        return isMarried;
    }

    public void setIsMarried(Boolean isMarried) {
        this.isMarried = isMarried;
    }

    public Person() {
    }

    public Person(String name, String sex, int age, Boolean isMarried) {
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.isMarried = isMarried;
    }
    public static boolean marryWith(Person p1,Person p2){
        if((p1.getIsMarried()==false)&&(p2.getIsMarried()==false)){
            if(p1.getSex().equals(p2.getSex())==false){
                if((p1.getAge()>=20)&&(p2.getAge()>=19)){
                    System.out.println(p1.getName()+"和"+p2.getName()+"结婚成功");
                    return true;
                }else {
                    System.out.println("结婚失败");
                }
            }
        }
        return true;
    }

    public void study(String school){
        System.out.println(this.getName()+"在"+school+"学校学习");
    }
}
public class homework3 {
    public static void main(String[] args) {
        Person person=new Person("飞龙在天","男",22,false);
        Person person2=new Person("南宫翠花","女",21,false);
        Person.marryWith(person,person2);
        Person person3=new Person("欧阳铁柱","男",19,false){
            @Override
            public void study(String school) {
                System.out.println("请输入学习时间");
                int time= new Scanner(System.in).nextInt();
                System.out.println(super.getName()+"在"+school+"学校学习了"+time+"年");
            }
        };
        person3.study("泉州职业技术大学");
    }
}

